#include<bits/stdc++.h>
using namespace std;
long long t,a,b;
int main()
{
	freopen("sub.in","r",stdin); 
	freopen("sub.out","w",stdout); 
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>t;
	while(t--)
	{
		cin>>a>>b;
		if((a>0&&b<0)||(a<0&&b>0))
			cout<<min(abs(a),min(abs(b),abs(a+b)))<<'\n'; 
		else
			cout<<0<<'\n';
	}
	return 0;
 } 
